<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test2::Util::HashBase - Build hash based classes. - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/Test2::Util::HashBase">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Test2::Util::HashBase.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/Test2::Util::HashBase">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/Test2::Util::HashBase">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/Test2::Util::HashBase">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/Test2::Util::HashBase">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/Test2::Util::HashBase">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/Test2::Util::HashBase">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/Test2::Util::HashBase">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/Test2::Util::HashBase">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/Test2::Util::HashBase">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/Test2::Util::HashBase">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/Test2::Util::HashBase">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/Test2::Util::HashBase">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/Test2::Util::HashBase">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/Test2::Util::HashBase">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/Test2::Util::HashBase">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/Test2::Util::HashBase">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/Test2::Util::HashBase">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/Test2::Util::HashBase">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/Test2::Util::HashBase">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/Test2::Util::HashBase">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/Test2::Util::HashBase">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/Test2::Util::HashBase">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/Test2::Util::HashBase">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/Test2::Util::HashBase">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/Test2::Util::HashBase">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/Test2::Util::HashBase">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/Test2::Util::HashBase">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/Test2::Util::HashBase">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/Test2::Util::HashBase">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/Test2::Util::HashBase">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/Test2::Util::HashBase">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/Test2::Util::HashBase">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/Test2::Util::HashBase">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/Test2::Util::HashBase">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/Test2::Util::HashBase">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/Test2::Util::HashBase">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/Test2::Util::HashBase">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/Test2::Util::HashBase">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/Test2::Util::HashBase">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/Test2::Util::HashBase">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/Test2::Util::HashBase">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/Test2::Util::HashBase">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/Test2::Util::HashBase">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/Test2::Util::HashBase">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/Test2::Util::HashBase">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/Test2::Util::HashBase">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/Test2::Util::HashBase">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/Test2::Util::HashBase">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/Test2::Util::HashBase">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/Test2::Util::HashBase">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/Test2::Util::HashBase">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/Test2::Util::HashBase">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/Test2::Util::HashBase">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/Test2::Util::HashBase">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/Test2::Util::HashBase">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/Test2::Util::HashBase">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/Test2::Util::HashBase">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/Test2::Util::HashBase">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/Test2::Util::HashBase">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/Test2::Util::HashBase">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/Test2::Util::HashBase">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/Test2::Util::HashBase">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/Test2::Util::HashBase">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/Test2::Util::HashBase">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/Test2::Util::HashBase">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/Test2::Util::HashBase">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/Test2::Util::HashBase">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/Test2::Util::HashBase">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/Test2::Util::HashBase">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/Test2::Util::HashBase">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/Test2::Util::HashBase">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/Test2::Util::HashBase">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/Test2::Util::HashBase">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/Test2::Util::HashBase">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/Test2::Util::HashBase">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/Test2::Util::HashBase">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/Test2::Util::HashBase">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/Test2::Util::HashBase">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/Test2::Util::HashBase">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/Test2::Util::HashBase">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Test2::Util::HashBase.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/Test2::Util::HashBase">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/Test2::Util::HashBase">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/Test2::Util::HashBase">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/Test2::Util::HashBase">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/Test2::Util::HashBase">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/Test2::Util::HashBase">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/Test2::Util::HashBase">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/Test2::Util::HashBase">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/Test2::Util::HashBase">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/Test2::Util::HashBase">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/Test2::Util::HashBase">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/Test2::Util::HashBase">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/Test2::Util::HashBase">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/Test2::Util::HashBase">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/Test2::Util::HashBase">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/Test2::Util::HashBase">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/Test2::Util::HashBase">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/Test2::Util::HashBase">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/Test2::Util::HashBase">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/Test2::Util::HashBase">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/Test2::Util::HashBase">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/Test2::Util::HashBase">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/Test2::Util::HashBase">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/Test2::Util::HashBase">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/Test2::Util::HashBase">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/Test2::Util::HashBase">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/Test2::Util::HashBase">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/Test2::Util::HashBase">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/Test2::Util::HashBase">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/Test2::Util::HashBase">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/Test2::Util::HashBase">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/Test2::Util::HashBase">5.35.1</a>
          <a class="dropdown-item active" href="./Test2::Util::HashBase.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="./Test2::Util::HashBase.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="./Test2::Util::HashBase.html">Test2::Util::HashBase</a>
          <div id="more">
            (<a href="./Test2::Util::HashBase.txt">source</a>,
            <a href="https://metacpan.org/pod/Test2::Util::HashBase">CPAN</a>)
          </div>
            <div id="moduleversion">version 1.302183</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#THIS-IS-A-BUNDLED-COPY-OF-HASHBASE">THIS IS A BUNDLED COPY OF HASHBASE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#METHODS">METHODS</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#PROVIDED-BY-HASH-BASE">PROVIDED BY HASH BASE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#HOOKS">HOOKS</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#ACCESSORS">ACCESSORS</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#READ/WRITE">READ/WRITE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#READ-ONLY">READ ONLY</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#DEPRECATED-SETTER">DEPRECATED SETTER</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#NO-SETTER">NO SETTER</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#NO-READER">NO READER</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#CONSTANT-ONLY">CONSTANT ONLY</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#SUBCLASSING">SUBCLASSING</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#GETTING-A-LIST-OF-ATTRIBUTES-FOR-A-CLASS">GETTING A LIST OF ATTRIBUTES FOR A CLASS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#SOURCE">SOURCE</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#MAINTAINERS">MAINTAINERS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#AUTHORS">AUTHORS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="./Test2::Util::HashBase.html#COPYRIGHT">COPYRIGHT</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="./Test2::Util::HashBase.html#NAME">#</a>NAME</h1>

<p>Test2::Util::HashBase - Build hash based classes.</p>

<h1 id="SYNOPSIS"><a class="permalink" href="./Test2::Util::HashBase.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<p>A class:</p>

<pre><code>package My::Class;
use strict;
use warnings;

# Generate 3 accessors
use Test2::Util::HashBase qw/foo -bar ^baz &lt;bat &gt;ban +boo/;

# Chance to initialize defaults
sub init {
    my $self = shift;    # No other args
    $self-&gt;{+FOO} ||= &quot;foo&quot;;
    $self-&gt;{+BAR} ||= &quot;bar&quot;;
    $self-&gt;{+BAZ} ||= &quot;baz&quot;;
    $self-&gt;{+BAT} ||= &quot;bat&quot;;
    $self-&gt;{+BAN} ||= &quot;ban&quot;;
    $self-&gt;{+BOO} ||= &quot;boo&quot;;
}

sub print {
    print join &quot;, &quot; =&gt; map { $self-&gt;{$_} } FOO, BAR, BAZ, BAT, BAN, BOO;
}</code></pre>

<p>Subclass it</p>

<pre><code>package My::Subclass;
use strict;
use warnings;

# Note, you should subclass before loading HashBase.
use base &#39;My::Class&#39;;
use Test2::Util::HashBase qw/bub/;

sub init {
    my $self = shift;

    # We get the constants from the base class for free.
    $self-&gt;{+FOO} ||= &#39;SubFoo&#39;;
    $self-&gt;{+BUB} ||= &#39;bub&#39;;

    $self-&gt;SUPER::init();
}</code></pre>

<p>use it:</p>

<pre><code>package main;
use strict;
use warnings;
use My::Class;

# These are all functionally identical
my $one   = My::Class-&gt;new(foo =&gt; &#39;MyFoo&#39;, bar =&gt; &#39;MyBar&#39;);
my $two   = My::Class-&gt;new({foo =&gt; &#39;MyFoo&#39;, bar =&gt; &#39;MyBar&#39;});
my $three = My::Class-&gt;new([&#39;MyFoo&#39;, &#39;MyBar&#39;]);

# Readers!
my $foo = $one-&gt;foo;    # &#39;MyFoo&#39;
my $bar = $one-&gt;bar;    # &#39;MyBar&#39;
my $baz = $one-&gt;baz;    # Defaulted to: &#39;baz&#39;
my $bat = $one-&gt;bat;    # Defaulted to: &#39;bat&#39;
# &#39;&gt;ban&#39; means setter only, no reader
# &#39;+boo&#39; means no setter or reader, just the BOO constant

# Setters!
$one-&gt;set_foo(&#39;A Foo&#39;);

#&#39;-bar&#39; means read-only, so the setter will throw an exception (but is defined).
$one-&gt;set_bar(&#39;A bar&#39;);

# &#39;^baz&#39; means deprecated setter, this will warn about the setter being
# deprecated.
$one-&gt;set_baz(&#39;A Baz&#39;);

# &#39;&lt;bat&#39; means no setter defined at all
# &#39;+boo&#39; means no setter or reader, just the BOO constant

$one-&gt;{+FOO} = &#39;xxx&#39;;</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="./Test2::Util::HashBase.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>This package is used to generate classes based on hashrefs. Using this class will give you a <code>new()</code> method, as well as generating accessors you request. Generated accessors will be getters, <code>set_ACCESSOR</code> setters will also be generated for you. You also get constants for each accessor (all caps) which return the key into the hash for that accessor. Single inheritance is also supported.</p>

<h1 id="THIS-IS-A-BUNDLED-COPY-OF-HASHBASE"><a class="permalink" href="./Test2::Util::HashBase.html#THIS-IS-A-BUNDLED-COPY-OF-HASHBASE">#</a><a id="THIS"></a>THIS IS A BUNDLED COPY OF HASHBASE</h1>

<p>This is a bundled copy of <a href="./Object::HashBase.html">Object::HashBase</a>. This file was generated using the <code>/home/exodist/perl5/perlbrew/perls/main/bin/hashbase_inc.pl</code> script.</p>

<h1 id="METHODS"><a class="permalink" href="./Test2::Util::HashBase.html#METHODS">#</a>METHODS</h1>

<h2 id="PROVIDED-BY-HASH-BASE"><a class="permalink" href="./Test2::Util::HashBase.html#PROVIDED-BY-HASH-BASE">#</a><a id="PROVIDED"></a>PROVIDED BY HASH BASE</h2>

<dl>

<dt id="$it-=-$class-&gt;new(%PAIRS)"><a class="permalink" href="./Test2::Util::HashBase.html#$it-=-$class-%3Enew(%25PAIRS)">#</a><a id="it-class-new-PAIRS"></a>$it = $class-&gt;new(%PAIRS)</dt>
<dd>

</dd>
<dt id="$it-=-$class-&gt;new(\%PAIRS)"><a class="permalink" href="./Test2::Util::HashBase.html#$it-=-$class-%3Enew(%5C%25PAIRS)">#</a><a id="it-class-new-PAIRS1"></a>$it = $class-&gt;new(\%PAIRS)</dt>
<dd>

</dd>
<dt id="$it-=-$class-&gt;new(\@ORDERED_VALUES)"><a class="permalink" href="./Test2::Util::HashBase.html#$it-=-$class-%3Enew(%5C@ORDERED_VALUES)">#</a><a id="it-class-new-ORDERED_VALUES"></a>$it = $class-&gt;new(\@ORDERED_VALUES)</dt>
<dd>

<p>Create a new instance.</p>

<p>HashBase will not export <code>new()</code> if there is already a <code>new()</code> method in your packages inheritance chain.</p>

<p><b>If you do not want this method you can define your own</b> you just have to declare it before loading <a href="./Test2::Util::HashBase.html">Test2::Util::HashBase</a>.</p>

<pre><code>package My::Package;

# predeclare new() so that HashBase does not give us one.
sub new;

use Test2::Util::HashBase qw/foo bar baz/;

# Now we define our own new method.
sub new { ... }</code></pre>

<p>This makes it so that HashBase sees that you have your own <code>new()</code> method. Alternatively you can define the method before loading HashBase instead of just declaring it, but that scatters your use statements.</p>

<p>The most common way to create an object is to pass in key/value pairs where each key is an attribute and each value is what you want assigned to that attribute. No checking is done to verify the attributes or values are valid, you may do that in <code>init()</code> if desired.</p>

<p>If you would like, you can pass in a hashref instead of pairs. When you do so the hashref will be copied, and the copy will be returned blessed as an object. There is no way to ask HashBase to bless a specific hashref.</p>

<p>In some cases an object may only have 1 or 2 attributes, in which case a hashref may be too verbose for your liking. In these cases you can pass in an arrayref with only values. The values will be assigned to attributes in the order the attributes were listed. When there is inheritance involved the attributes from parent classes will come before subclasses.</p>

</dd>
</dl>

<h2 id="HOOKS"><a class="permalink" href="./Test2::Util::HashBase.html#HOOKS">#</a>HOOKS</h2>

<dl>

<dt id="$self-&gt;init()"><a class="permalink" href="./Test2::Util::HashBase.html#$self-%3Einit()">#</a><a id="init"></a><a id="self-init"></a>$self-&gt;init()</dt>
<dd>

<p>This gives you the chance to set some default values to your fields. The only argument is <code>$self</code> with its indexes already set from the constructor.</p>

<p><b>Note:</b> Test2::Util::HashBase checks for an init using <code>$class-&gt;can(&#39;init&#39;)</code> during construction. It DOES NOT call <code>can()</code> on the created object. Also note that the result of the check is cached, it is only ever checked once, the first time an instance of your class is created. This means that adding an <code>init()</code> method AFTER the first construction will result in it being ignored.</p>

</dd>
</dl>

<h1 id="ACCESSORS"><a class="permalink" href="./Test2::Util::HashBase.html#ACCESSORS">#</a>ACCESSORS</h1>

<h2 id="READ/WRITE"><a class="permalink" href="./Test2::Util::HashBase.html#READ/WRITE">#</a><a id="READ"></a><a id="READ-WRITE"></a>READ/WRITE</h2>

<p>To generate accessors you list them when using the module:</p>

<pre><code>use Test2::Util::HashBase qw/foo/;</code></pre>

<p>This will generate the following subs in your namespace:</p>

<dl>

<dt id="foo()"><a class="permalink" href="./Test2::Util::HashBase.html#foo()">#</a><a id="foo"></a>foo()</dt>
<dd>

<p>Getter, used to get the value of the <code>foo</code> field.</p>

</dd>
<dt id="set_foo()"><a class="permalink" href="./Test2::Util::HashBase.html#set_foo()">#</a><a id="set_foo"></a>set_foo()</dt>
<dd>

<p>Setter, used to set the value of the <code>foo</code> field.</p>

</dd>
<dt id="FOO()"><a class="permalink" href="./Test2::Util::HashBase.html#FOO()">#</a><a id="FOO"></a>FOO()</dt>
<dd>

<p>Constant, returns the field <code>foo</code>&#39;s key into the class hashref. Subclasses will also get this function as a constant, not simply a method, that means it is copied into the subclass namespace.</p>

<p>The main reason for using these constants is to help avoid spelling mistakes and similar typos. It will not help you if you forget to prefix the &#39;+&#39; though.</p>

</dd>
</dl>

<h2 id="READ-ONLY"><a class="permalink" href="./Test2::Util::HashBase.html#READ-ONLY">#</a><a id="READ1"></a>READ ONLY</h2>

<pre><code>use Test2::Util::HashBase qw/-foo/;</code></pre>

<dl>

<dt id="set_foo()1"><a class="permalink" href="./Test2::Util::HashBase.html#set_foo()1">#</a><a id="set_foo1"></a>set_foo()</dt>
<dd>

<p>Throws an exception telling you the attribute is read-only. This is exported to override any active setters for the attribute in a parent class.</p>

</dd>
</dl>

<h2 id="DEPRECATED-SETTER"><a class="permalink" href="./Test2::Util::HashBase.html#DEPRECATED-SETTER">#</a><a id="DEPRECATED"></a>DEPRECATED SETTER</h2>

<pre><code>use Test2::Util::HashBase qw/^foo/;</code></pre>

<dl>

<dt id="set_foo()2"><a class="permalink" href="./Test2::Util::HashBase.html#set_foo()2">#</a><a id="set_foo2"></a>set_foo()</dt>
<dd>

<p>This will set the value, but it will also warn you that the method is deprecated.</p>

</dd>
</dl>

<h2 id="NO-SETTER"><a class="permalink" href="./Test2::Util::HashBase.html#NO-SETTER">#</a><a id="NO"></a>NO SETTER</h2>

<pre><code>use Test2::Util::HashBase qw/&lt;foo/;</code></pre>

<p>Only gives you a reader, no <code>set_foo</code> method is defined at all.</p>

<h2 id="NO-READER"><a class="permalink" href="./Test2::Util::HashBase.html#NO-READER">#</a><a id="NO1"></a>NO READER</h2>

<pre><code>use Test2::Util::HashBase qw/&gt;foo/;</code></pre>

<p>Only gives you a write (<code>set_foo</code>), no <code>foo</code> method is defined at all.</p>

<h2 id="CONSTANT-ONLY"><a class="permalink" href="./Test2::Util::HashBase.html#CONSTANT-ONLY">#</a><a id="CONSTANT"></a>CONSTANT ONLY</h2>

<pre><code>use Test2::Util::HashBase qw/+foo/;</code></pre>

<p>This does not create any methods for you, it just adds the <code>FOO</code> constant.</p>

<h1 id="SUBCLASSING"><a class="permalink" href="./Test2::Util::HashBase.html#SUBCLASSING">#</a>SUBCLASSING</h1>

<p>You can subclass an existing HashBase class.</p>

<pre><code>use base &#39;Another::HashBase::Class&#39;;
use Test2::Util::HashBase qw/foo bar baz/;</code></pre>

<p>The base class is added to <code>@ISA</code> for you, and all constants from base classes are added to subclasses automatically.</p>

<h1 id="GETTING-A-LIST-OF-ATTRIBUTES-FOR-A-CLASS"><a class="permalink" href="./Test2::Util::HashBase.html#GETTING-A-LIST-OF-ATTRIBUTES-FOR-A-CLASS">#</a><a id="GETTING"></a>GETTING A LIST OF ATTRIBUTES FOR A CLASS</h1>

<p>Test2::Util::HashBase provides a function for retrieving a list of attributes for an Test2::Util::HashBase class.</p>

<dl>

<dt id="@list-=-Test2::Util::HashBase::attr_list($class)"><a class="permalink" href="./Test2::Util::HashBase.html#@list-=-Test2::Util::HashBase::attr_list($class)">#</a><a id="list-Test2::Util::HashBase::attr_list-class"></a>@list = Test2::Util::HashBase::attr_list($class)</dt>
<dd>

</dd>
<dt id="@list-=-$class-&gt;Test2::Util::HashBase::attr_list()"><a class="permalink" href="./Test2::Util::HashBase.html#@list-=-$class-%3ETest2::Util::HashBase::attr_list()">#</a><a id="list-class-Test2::Util::HashBase::attr_list"></a>@list = $class-&gt;Test2::Util::HashBase::attr_list()</dt>
<dd>

<p>Either form above will work. This will return a list of attributes defined on the object. This list is returned in the attribute definition order, parent class attributes are listed before subclass attributes. Duplicate attributes will be removed before the list is returned.</p>

<p><b>Note:</b> This list is used in the <code>$class-&gt;new(\@ARRAY)</code> constructor to determine the attribute to which each value will be paired.</p>

</dd>
</dl>

<h1 id="SOURCE"><a class="permalink" href="./Test2::Util::HashBase.html#SOURCE">#</a>SOURCE</h1>

<p>The source code repository for HashBase can be found at <i>http://github.com/Test-More/HashBase/</i>.</p>

<h1 id="MAINTAINERS"><a class="permalink" href="./Test2::Util::HashBase.html#MAINTAINERS">#</a>MAINTAINERS</h1>

<dl>

<dt id="Chad-Granum"><a class="permalink" href="./Test2::Util::HashBase.html#Chad-Granum">#</a><a id="Chad-Granum-&lt;exodist@cpan.org&gt;"></a><a id="Chad"></a><a id="Chad-Granum-exodist-cpan.org"></a>Chad Granum &lt;exodist@cpan.org&gt;</dt>
<dd>

</dd>
</dl>

<h1 id="AUTHORS"><a class="permalink" href="./Test2::Util::HashBase.html#AUTHORS">#</a>AUTHORS</h1>

<dl>

<dt id="Chad-Granum1"><a class="permalink" href="./Test2::Util::HashBase.html#Chad-Granum1">#</a><a id="Chad-Granum-&lt;exodist@cpan.org&gt;1"></a><a id="Chad1"></a><a id="Chad-Granum-exodist-cpan.org1"></a>Chad Granum &lt;exodist@cpan.org&gt;</dt>
<dd>

</dd>
</dl>

<h1 id="COPYRIGHT"><a class="permalink" href="./Test2::Util::HashBase.html#COPYRIGHT">#</a>COPYRIGHT</h1>

<p>Copyright 2017 Chad Granum &lt;exodist@cpan.org&gt;.</p>

<p>This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>

<p>See <i>http://dev.perl.org/licenses/</i></p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
